﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;
using l1cs.server.model;

namespace l1cs.server.clientpackets
{
    public class C_NPCTalkAction : ClientBasePacket
    {
        private const String _C_NPC_TALK_ACTION = "[C] C_NPCTalkAction";
        private static Logger _log = Logger.getLogger( typeof( C_NPCTalkAction ).FullName );

        public C_NPCTalkAction( byte[] decrypt, ClientThread client )
            : base( decrypt )
        {
            int objectId = readD();
            String action = readS();
            L1PcInstance activeChar = client.getActiveChar();

            L1Object obj = L1World.getInstance().findObject( objectId );
            if ( obj == null )
            {
                _log.warning( "object not found, oid " + objectId );
                return;
            }
            L1NpcInstance npc = (L1NpcInstance)obj;
            npc.onFinalAction( activeChar, action );
        }

        override
        public String getType()
        {
            return _C_NPC_TALK_ACTION;
        }
    }
}